package com.isunland.managesystem.ui;

import android.support.v4.app.Fragment;
import android.view.MenuItem;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.OderSaleContent;
import com.isunland.managesystem.ui.AddOrderSaleFragment.CallBack;
import com.isunland.managesystem.utils.LogUtil;

public class AddOrderSaleActivity extends TableHeaderPagerActivity implements CallBack {

  private int[] titles = { R.string.order_detail, R.string.materiel_detail_list };

  @Override protected Fragment createFragmentOne() {
    return new AddOrderSaleFragment();
  }

  //物料明细列表
  @Override protected Fragment createFragmentTwo() {

    //		return new AddMaterielListFragment();
    OderSaleContent orderContent = new OderSaleContent();
    orderContent.setId("0");
    return AddMaterielListFragment.newInstance(orderContent);
  }

  @Override protected int[] createTitle() {
    return titles;
  }

  @Override public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        //			LogUtil.i("主表是否保存"+AddOrderSaleFragment.isSave);
        //			if (AddOrderSaleFragment.isSave==false) {
        //				this.finish();
        //			}else {
        //				setResult(RESULT_OK);
        //				this.finish();
        //				//onActivityResult
        //			}
        //			AddOrderSaleFragment.isSave=false;

        break;

      default:
        break;
    }
    return super.onOptionsItemSelected(item);
  }

  //回调实现的方法
  @Override public void onRefresh(OderSaleContent morderContent) {
    LogUtil.i("morderContent==" + morderContent.getStorageId());
    setNavigateTo(1);
    //更新content
    AddMaterielListFragment.getContent(morderContent);
  }

  @Override public int getHeaderPosition() {
    return 1;
  }
}
